const Koa = require("Koa"); // 引入Koa
const views = require("koa-views");
const router = require("koa-router")();
const nunjucks = require("nunjucks");
const static = require('koa-static')
const app = new Koa(); // 创建Koa应用
//__dirname是当前项目的绝对路径
app.use(static(__dirname + "/views"));

app.use(views(__dirname + "/views", {
    map: { html: "nunjucks" }
}));

router.get("/", async ctx => {
    ctx.body = `<a href="/pc">pc首页</a>
    <a href="/phone">phone首页</a>`
})
router.get("/pc", async ctx => {
    await ctx.render("home.html");
});
router.get("/phone", async ctx => {
    await ctx.render("home_page.html");
});



app.use(router.routes());
app.listen(3000, () => {
    console.log("启动成功");
});